package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.entity.PageResult;
import com.itheima.converter.OrderConverter;
import com.itheima.dto.OrderDTO;
import com.itheima.dto.OrderPageQueryDTO;
import com.itheima.mapper.OrderMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.Setmeal;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;
    /**
     * 分页查询
     */
    @Override
    public PageResult pageQuery(OrderPageQueryDTO orderPageQueryDTO) {
        PageHelper.startPage(orderPageQueryDTO.getCurrentPage(),orderPageQueryDTO.getPageSize());
        Page<Order> orderPage=orderMapper.pageQuery(orderPageQueryDTO);
        PageResult pageResult =new PageResult(orderPage.getTotal(),orderPage.getResult());
        return pageResult;
    }
    /**
     * 修改预约状态
     * @param orderDTO
     */
    @Override
    public void updateOrderStatus(OrderDTO orderDTO) {
        Order order = OrderConverter.orderDTOToOrder(orderDTO);
        orderMapper.updateOrder(order);
    }
}
